//
//  PlayRadioView.m
//  news
//
//  Created by lanou on 15/12/17.
//  Copyright © 2015年 lanou. All rights reserved.
//

#import "PlayRadioView.h"
#import "BlurImageView.h"

@implementation PlayRadioView

-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
    UIView *result = [super hitTest:point withEvent:event];
    if (result == self) {
        return nil;
    } else {
        return result;
    }
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        BlurImageView *blurImageView = [[BlurImageView alloc] initWithFrame:CGRectMake(0, 0, kWidth, self.bounds.size.height)]
        ;
        [self addSubview:blurImageView];
        
        self.backBtn = [UIButton buttonWithType:UIButtonTypeSystem];
        self.backBtn.frame = CGRectMake(10, 30, 30, 30);
        [self.backBtn setImage:[UIImage imageNamed:@"down"] forState:UIControlStateNormal];
        self.backBtn.tintColor = [UIColor whiteColor];
        [self addSubview:self.backBtn];
        
        
        self.pictureView = [[UIImageView alloc] initWithFrame:CGRectMake(self.bounds.size.width / 3.4, self.bounds.size.height / 5.0, self.bounds.size.width / 2.5, self.bounds.size.width / 2.5)];
        self.pictureView.image = [UIImage imageNamed:@"placeHolder.jpg"];
        [self setImageViewWithLayer:self.pictureView];
        [self addSubview:self.pictureView];
        
        
        self.playBtn = [UIButton buttonWithType:UIButtonTypeSystem];
        [self setButton:self.playBtn image:@"player_play" CGRect:CGRectMake(kWidth / 3 * 1.22, self.bounds.size.height / 3 , 60, 60)];
        
        self.nextBtn = [UIButton buttonWithType:UIButtonTypeSystem];
        [self setButton:self.nextBtn image:@"player_next" CGRect:CGRectMake(kWidth / 5.0 * 4, self.bounds.size.height / 2.7, 40, 40)];
        
        self.prevBtn = [UIButton buttonWithType:UIButtonTypeSystem];
        [self setButton:self.prevBtn image:@"player_prev" CGRect:CGRectMake(kWidth / 12.0, self.bounds.size.height / 2.7, 40, 40)];
        
        
        self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.bounds.size.height / 5.0 * 4, kWidth, 40)];
        self.titleLabel.textColor = [UIColor whiteColor];
        self.titleLabel.numberOfLines = 0;
        self.titleLabel.font = [UIFont systemFontOfSize:15];
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        [self addSubview:self.titleLabel];
        
        
    }
    return self;
}


// 设置图片为圆形
- (void)setImageViewWithLayer:(UIImageView *)imageView {
    
    imageView.layer.masksToBounds = YES;
    imageView.layer.borderWidth = 2;
    imageView.layer.cornerRadius = imageView.bounds.size.height / 2;
    imageView.layer.borderColor = [[UIColor grayColor] CGColor];

}

- (void)setButton:(UIButton *)button image:(NSString *)imageName CGRect:(CGRect)CGRect {
    
    button.frame = CGRect;
    button.tintColor = [UIColor whiteColor];
    [button setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [self addSubview:button];
}

- (void)setLabel:(UILabel *)label {
    label.textColor = [UIColor grayColor];
    label.font = [UIFont systemFontOfSize:13];
    label.text = @"0:00";
    [self addSubview:label];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
